package com.qingcheng.controller;

import com.qingcheng.entity.PageResult;
import com.qingcheng.entity.Result;
import com.qingcheng.pojo.order.Order;
import com.qingcheng.pojo.order.Orders;
import com.qingcheng.pojo.order.ReturnOrder;
import com.qingcheng.service.ReturnOrderService;
import com.qingcheng.vo.goods.ReturnOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/returnOrder")
public class ReturnOrderController {

    @Autowired
    private ReturnOrderService returnOrderService;

    @GetMapping("/selectCount")
    public Result selectCount(){
        return new Result<>(200,"查询成功",returnOrderService.selectCount());
    }

    @PostMapping("/findPage")
    public PageResult<ReturnOrder> findPage(@RequestBody Map<String,Object> searchMap, int page, int size){
        return  returnOrderService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public ReturnOrder findById(String id){
        return returnOrderService.findById(Long.valueOf(id));
    }

    @GetMapping("/findReturnOrder")
    public ReturnOrderVO findReturnOrder(String orderId){
        return returnOrderService.findReturnOrder(orderId);
    }

    @PostMapping("/returnOk")
    public Result returnOk(@RequestBody Map map){
        returnOrderService.returnOk(map);
        return new Result(200,"退货成功","");
    }

    @PostMapping("/rejectReturn")
    public Result rejectReturn(@RequestBody Map map){
        returnOrderService.rejectReturn(map);
        return new Result(200,"退货成功","");
    }


}
